package com.wcw.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.gson.Gson;
import com.wcw.entity.Book;
import com.wcw.mapper.BookMapper;
import com.wcw.mapper.CacheMapper;

@Service
public class TestCacheService {

	@Autowired
	private BookMapper bookMapper;

	@Autowired
	private CacheMapper cacheMapper;
	
	@Transactional(rollbackFor = Throwable.class)
	public void selectBookById(Integer id) {
		Book bookMap = bookMapper.selectBookDetail(id);
		System.out.println(new Gson().toJson(bookMap));
//		System.out.println("=====================分隔========================");
//		bookMap = bookMapper.selectBookDetail(id);
//		System.out.println(new Gson().toJson(bookMap));
	}
	
	@Transactional(rollbackFor = Throwable.class)
	public void selectBookById2(Integer id) {
		Book bookMap = bookMapper.selectBookDetail(id);
		System.out.println(new Gson().toJson(bookMap));
	}
	
	@Transactional(rollbackFor = Throwable.class)
	public void selectBookById3(Integer id) {
		Book bookMap = cacheMapper.selectBookDetail(id);
		System.out.println(new Gson().toJson(bookMap));
	}
	
	@Transactional(rollbackFor = Throwable.class)
	public void selectBookById4(Integer id) {
		Book bookMap = cacheMapper.selectBookDetail(id);
		System.out.println(new Gson().toJson(bookMap));
	}
}
